﻿<%@ Page Language="C#" ValidateRequest="false" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true" CodeFile="AddEditAlbum.aspx.cs" Inherits="AddEditAlbum" Title="Thêm / Cập Album" %>
<%@ Register Src="../Controls/FileUploadResize.ascx" TagName="FileUploadResize" TagPrefix="mb" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<%@ Import Namespace="DTO" %>

<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" Runat="Server">
<script src="<%=Globals.ApplicationPath%>js/jquery-1.3.2.js" type="text/javascript"></script>
<script src="<%=Globals.ApplicationPath%>js/jquery.MultiFile.js" type="text/javascript"></script>

<div class="title">
      <asp:Literal runat="server" ID="lblNewArticle" Text="Thêm tin mới" />
      <asp:Literal runat="server" ID="lblEditArticle" Text="Cập nhật tin" Visible="false" />
</div>
<div class="body">
   <p></p>
   <asp:DetailsView ID="dvwArticle" runat="server" AutoGenerateRows="False" DataKeyNames="ID" DataSourceID="objCurrArticle" Width="100%"
      DefaultMode="Insert" HeaderText="Thông tin chi tiết" OnDataBound="dvwArticle_DataBound" OnModeChanged="dvwArticle_ModeChanged">
      <FieldHeaderStyle Width="100px" />
      <Fields>
         <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
            SortExpression="ID" />
         <asp:BoundField DataField="AddedDate" HeaderText="Ngày thêm" InsertVisible="False"
            ReadOnly="True" SortExpression="AddedDate" DataFormatString="{0:f}" />
         <asp:BoundField DataField="AddedBy" HeaderText="Người thêm" InsertVisible="False" ReadOnly="True"
            SortExpression="AddedBy" />
         <asp:BoundField DataField="ViewCount" HeaderText="Lượt xem" InsertVisible="False"
            ReadOnly="True" SortExpression="ViewCount" />
         <asp:TemplateField HeaderText="Tiêu đề" SortExpression="Title">
            <ItemTemplate>
               <asp:Label ID="lblTitle" runat="server" Text='<%# Eval("Title") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
               <asp:TextBox ID="txtTitle" runat="server" Text='<%# Bind("Title") %>' Width="100%" MaxLength="256"></asp:TextBox>
               <asp:RequiredFieldValidator ID="valRequireTitle" runat="server" ControlToValidate="txtTitle" SetFocusOnError="true"
                  Text="The Title field is required." ToolTip="The Title field is required." Display="Dynamic"></asp:RequiredFieldValidator>
            </EditItemTemplate>
         </asp:TemplateField> 
         <asp:TemplateField HeaderText="Ảnh bìa" SortExpression="imageUrl">
            <ItemTemplate>
               <asp:Label ID="lblimageUrl" runat="server" Text='<%# Eval("imageUrl") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
            <asp:TextBox ID="txtimageUrl" runat="server" Text='<%# Bind("imageUrl") %>' Width="100%" MaxLength="256"></asp:TextBox>
            </EditItemTemplate>
         </asp:TemplateField>              
         <asp:TemplateField HeaderText="Ghi chú" SortExpression="Body">
            <ItemTemplate>
               <asp:Label ID="lblBody" runat="server" Text='<%# Eval("Body") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
               <fckeditorv2:fckeditor id="txtBody" runat="server" Value='<%# Bind("Body") %>'
                  ToolbarSet="Basic" Height="200px" Width="100%" />
            </EditItemTemplate>
         </asp:TemplateField>         
          <asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/nhaplai.png" 
              CancelText="Nhập  lại" InsertImageUrl="~/Images/themmoi.png" 
              InsertText="Thêm mới" ShowInsertButton="True" ShowEditButton="True"
              UpdateImageUrl="~/Images/capnhat.png" UpdateText="Cập nhật" />                
      </Fields>
   </asp:DetailsView>
   <asp:ObjectDataSource ID="objCurrArticle" runat="server" DeleteMethod="DeleteArticle"
      InsertMethod="InsertArticle" SelectMethod="GetArticleByID" TypeName="BLL.Article.Article"
      UpdateMethod="UpdateArticle">
      <DeleteParameters>
         <asp:Parameter Name="id" Type="Int32" />
      </DeleteParameters>
      <UpdateParameters>
         <asp:Parameter Name="id" Type="Int32" />
         <asp:Parameter Name="categoryID" Type="Int32" DefaultValue="2" />
         <asp:Parameter Name="title" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="Abstract" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="body" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="releaseDate" Type="DateTime" />
         <asp:Parameter Name="expireDate" Type="DateTime" />
         <asp:Parameter Name="approved" Type="Boolean" />
         <asp:Parameter Name="listed" Type="Boolean" />
         <asp:Parameter Name="commentsEnabled" Type="Boolean" />
         <asp:Parameter Name="onlyForMembers" Type="Boolean" />
         <asp:Parameter Name="imageUrl" Type="String" />
      </UpdateParameters>
      <SelectParameters>
         <asp:QueryStringParameter Name="articleID" QueryStringField="ID" Type="Int32" />
      </SelectParameters>
      <InsertParameters>
         <asp:Parameter Name="categoryID" Type="Int32" DefaultValue="2" />
         <asp:Parameter Name="title" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="Abstract" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="body" Type="String" ConvertEmptyStringToNull="false" />
         <asp:Parameter Name="releaseDate" Type="DateTime" />
         <asp:Parameter Name="expireDate" Type="DateTime" />
         <asp:Parameter Name="approved" Type="Boolean" />
         <asp:Parameter Name="listed" Type="Boolean" />
         <asp:Parameter Name="commentsEnabled" Type="Boolean" />
         <asp:Parameter Name="onlyForMembers" Type="Boolean" />
         <asp:Parameter Name="imageUrl" Type="String" />
      </InsertParameters>     
   </asp:ObjectDataSource>   
   <p></p>
  <mb:FileUploadResize id="FileUploadResize1" runat="server" /> kích thước : 200 x 200  
   <asp:ObjectDataSource ID="objAllCategories" runat="server" SelectMethod="ListCategories"
      TypeName="BLL.Article.Category"></asp:ObjectDataSource>
</div>
<div class="bottom"></div>
</asp:Content>

